<html>
	<?php
		require_once("classes/User.php");
		require_once("classes/Database.php");
		require_once("classes/Head.php");
		require_once("classes/Section.php");
		require_once("classes/Image.php");
		require_once("classes/Title.php");
		require_once("classes/Paragraph.php");
		require_once("classes/LinkList.php");
		require_once("classes/EntryList.php");
		require_once("classes/Announcement.php");
		require_once("classes/Form.php");
		
		$head = new Head();
		
		if(!isset($_SESSION["login"])){
			session_start();
		}
		
		$user = $_SESSION["user"];
		if($_SESSION["login"]){
			$title = "Perquisar Candidatos";
		}else{
			$title = "Login Errado";
		}
		$head->addLayout("css/style.css");
		$head->addTitle($title);
		
		$head->printHead();
	?>
	<body id="body">
		<div id="struture">
			<div id="container">
		        <?php
		        
		        	$header = new Section("header");					
						$header->addElement(new Image("images/job.png", "logo", "100px", "100px"));
						
						$title = new Title("Ofertas de Emprego", "title");
						$header->addElement($title);
					$header->printSection();
		        	
		        	/* Left Page */
		        	$leftPage = new Section("leftPage");
					if($_SESSION["login"]){
						$leftPage->addElement(new Title("Informa&ccedil&atildeo", "menuTitle"));
						
						$leftPage->addElement(new Paragraph("Introduza algo para pesquisar", "menu"));
						$logout = new LinkList("menuEntry");
						$logout->addLink("Logout", "scripts/logout.php", new Image("images/leave.png", "icon", "16px", "16px"));
						$logout->addLink("Voltar", "home.php", new Image("images/leave.png", "icon", "16px", "16px"));
						$leftPage->addElement($logout);
						
						$leftPage->addElement(new Title("Pesquisar", "menuTitle"));
						
						$form = new Form("scripts/searchCandidate.php", "POST", "login");
						$form->addInput("", "text", "find", "input", "", "", TRUE);
						$form->addInput("", "submit", "", "button", "Pesquisar", "", FALSE);
						
						$leftPage->addElement($form);
						$leftPage->printSection();
						
						$content = new Section("content");
						
						$content->addElement(new Title("Pesquisa", "seccaoTitle"));
						if(isset($_SESSION["entry"])){
							$entry = $_SESSION["entry"];
							unset($_SESSION["entry"]);
							$content->addElement($entry);
						}else{
							$content->addElement(new Paragraph("Introduza os dados da sua pesquisa na caixa de pesquisa que se encontra
																&aacute esquerda da p&aacutegina.", "seccao"));
						}
						$content->printSection();
					}else{
						$text = "Login Errado.";
						$leftPage->addElement(new Title("ERRO", "menuTitle"));
						$leftPage->addElement(new Paragraph($text, "menu"));
						
						$leave = new LinkList("menuEntry");
						$leave->addLink("Voltar", "index.php", new Image("images/leave.png", "icon", "16px", "16px"));
						$leftPage->addElement($leave);
						$leftPage->printSection();
						
						$content = new Section("content");
						$content->addElement(new Title("ERRO", "seccaoTitle"));
						
						$content->printSection();
					}
					
					$footer = new Section("footer");
						$text = new Paragraph("Copyright&copy Nuno Pombo", "");
						$footer->addElement($text);
					$footer->printSection();
		        ?>
			</div>
		</div>
	</body>
</html>